/*
@Copyright:LintCode
@Author:   tjyemail
@Problem:  http://www.lintcode.com/problem/climbing-stairs
@Language: C++
@Datetime: 16-02-09 04:45
*/

class Solution {
public:
    /**
     * @param n: An integer
     * @return: An integer
     */
    int climbStairs(int n) {
        // write your code here
        int a=1,b=2,c;
        if (n==0)
            return 1;
        if (n<3)
            return n;
        n-=2;
        while(n--){
            c = a+b;
            a = b;
            b = c;
        }
        return c;
    }
};
